<?php
namespace App\Models\Traits;
use App\Models\GoodsCategory;
//以梯类形式展示goodsCategory
trait GoodsCategoryShowHelper{

    public static function goodsCategoryShow(){
        $category_list =  GoodsCategory::orderBy("path")->select("path","id","name","level")->get();
        foreach ($category_list as $key=>$val){
            $list[$val['id']] = self::struct_category_str($val['level']).$val['name'];
        }
        return $list;
    }
    private static function struct_category_str($long){
        $str = "";
        for ($i=0;$i<$long;$i++){
            $str.="----";
        }
        return $str;
    }

}
